package com.ruoyi.project.sale.deliver.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.sale.deliver.domain.Jlfhbd;
import com.ruoyi.project.sale.deliver.service.IJlfhbdService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 煤炭销售Controller
 * 
 * @author frank
 * @date 2024-08-17
 */
@RestController
@RequestMapping("/sale/deliver/jlfhbd")
public class JlfhbdController extends BaseController
{
    @Autowired
    private IJlfhbdService jlfhbdService;

    /**
     * 查询煤炭销售列表
     */
    @PreAuthorize("@ss.hasPermi('sale/deliver:jlfhbd:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jlfhbd jlfhbd)
    {
        startPage();
        List<Jlfhbd> list = jlfhbdService.selectJlfhbdList(jlfhbd);
        return getDataTable(list);
    }

    /**
     * 导出煤炭销售列表
     */
    @PreAuthorize("@ss.hasPermi('sale/deliver:jlfhbd:export')")
    @Log(title = "煤炭销售", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jlfhbd jlfhbd)
    {
        List<Jlfhbd> list = jlfhbdService.selectJlfhbdList(jlfhbd);
        ExcelUtil<Jlfhbd> util = new ExcelUtil<Jlfhbd>(Jlfhbd.class);
        util.exportExcel(response, list, "煤炭销售数据");
    }

    /**
     * 获取煤炭销售详细信息
     */
    @PreAuthorize("@ss.hasPermi('sale/deliver:jlfhbd:query')")
    @GetMapping(value = "/{jlFhbdoid}")
    public AjaxResult getInfo(@PathVariable("jlFhbdoid") String jlFhbdoid)
    {
        return success(jlfhbdService.selectJlfhbdByJlFhbdoid(jlFhbdoid));
    }

    /**
     * 新增煤炭销售
     */
    @PreAuthorize("@ss.hasPermi('sale/deliver:jlfhbd:add')")
    @Log(title = "煤炭销售", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jlfhbd jlfhbd)
    {
        return toAjax(jlfhbdService.insertJlfhbd(jlfhbd));
    }

    /**
     * 修改煤炭销售
     */
    @PreAuthorize("@ss.hasPermi('sale/deliver:jlfhbd:edit')")
    @Log(title = "煤炭销售", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jlfhbd jlfhbd)
    {
        return toAjax(jlfhbdService.updateJlfhbd(jlfhbd));
    }

    /**
     * 删除煤炭销售
     */
    @PreAuthorize("@ss.hasPermi('sale/deliver:jlfhbd:remove')")
    @Log(title = "煤炭销售", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jlFhbdoids}")
    public AjaxResult remove(@PathVariable String[] jlFhbdoids)
    {
        return toAjax(jlfhbdService.deleteJlfhbdByJlFhbdoids(jlFhbdoids));
    }
}
